# http://www.opennet.ru/docs/RUS/zlp/003.html - Пример сборки библиотеки
# VPATH - пути откуда, для поиска исходников.



all: clean library client server

VPATH = include
.PHONY = clean
FLAGS = -Wall -o
LIB = -Iinclude -Llibrary -lpthread -lMyNetwork

client: client.c
	gcc $(FLAGS) bin/client client.c  $(LIB) -lpanel -lncurses -lMyInterface

server: server.c
	gcc $(FLAGS) bin/server server.c  $(LIB) -lMyServerCore

library: network interface servercore

network: library/network.c
	gcc -c library/network.c -o library/network.o
	ar rc library/libMyNetwork.a library/*.o
	ranlib library/libMyNetwork.a

interface: library/interface.c
	gcc -c library/interface.c  -o library/interface.o -Iinclude
	ar rc library/libMyInterface.a library/*.o 
	ranlib library/libMyInterface.a
	
servercore: library/lobby.c library/ingame.c library/gameaction.c library/gamelogic.c
	gcc -c library/lobby.c  -o library/lobby.o -Iinclude
	gcc -c library/ingame.c  -o library/ingame.o -Iinclude
	gcc -c library/gameaction.c  -o library/gameaction.o -Iinclude
	gcc -c library/gamelogic.c  -o library/gamelogic.o -Iinclude
	ar rc library/libMyServerCore.a library/*.o
	ranlib library/libMyServerCore.a

clean:
	rm -f library/*.o
	rm -f library/*~
	rm -f library/*.a	
	rm -f include/*~
	rm -f bin/*
	rm -f *~
